package java_class_work.week03;

import java.util.Objects;

public class Demo06 {
    String name;
    int age;

    Demo06(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Demo06{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (o == null) {
            return false;
        }
        if (o == this) {
            return true;
        }
        if (o.getClass() != this.getClass()) {
            return false;
        }
        Demo06 d = (Demo06) o;
        return d.name.equals(this.name) && d.age == this.age;
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    public static void main(String[] args) {
        Demo06 z = new Demo06("张三", 88);
        System.out.println(z.toString());
    }
}
